﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using SufeiUtil;

namespace Live
{
    public abstract class BasePlatform
    {
        public HttpHelper mHelper = new HttpHelper();

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="url"></param>
        public abstract bool Init(string url);

        /// <summary>
        /// 取出房间id
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        protected string GetRoomId(string url)
        {
            Match match = Regex.Match(url, "\\d+");
            if (match.Success)
            {
                return match.Groups[0].Value;
            }
            return "";
        }
        /// <summary>
        /// 请求房间信息
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        protected abstract string ReqRoomInfo(string url);

        /// <summary>
        /// 是否正在直播
        /// </summary>
        /// <returns></returns>
        public abstract bool IsLive();

        /// <summary>
        /// 获取房间信息
        /// </summary>
        public abstract Room GetRoomInfo();

        /// <summary>
        /// 获取在线播放地址
        /// </summary>
        /// <returns></returns>
        public abstract string GetLivePlayUrl();
    }
}